package com.wc.AlgoOJ_train.train3_算法大礼包.c2_深度优先搜索.AG0304_马的旅行;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/28 16:39
 * @description http://43.138.190.70:8888/p/AG0304
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int t, n, m;
    static int N = 30;
    static String[] path = new String[N * N];
    static boolean[][] vis = new boolean[N][N];
    static boolean[][] isFault = new boolean[N][N];
    static int[] dx = new int[]{-2, -2, -1, -1, 1, 1, 2, 2};
    static int[] dy = new int[]{-1, 1, -2, 2, -2, 2, -1, 1};
    static char[] c = new char[N];

    public static void main(String[] args) {
        t = sc.nextInt();

        for (int i = 1, j = 'A'; i < 10; i++, j++) {
            c[i] = (char) j;
        }
        for (int i = 1; i <= t; i++) {
            m = sc.nextInt();
            n = sc.nextInt();
            path[1] = "A1";
            out.printf("Scenario #%d:\n", i);
            vis[1][1] = true;
            if (dfs(2, 1, 1)) {
                for (int j = 1; j <= m * n; j++) {
                    out.print(path[j]);
                }
                out.println();
            } else {
                out.println("impossible");
            }
            out.println();

            for (int j = 0; j <= n; j++) {
                Arrays.fill(vis[j], false);
                Arrays.fill(isFault[j], false);
            }
        }
        out.flush();
    }

    // u代表,该第几个了
    static boolean dfs(int u, int x, int y) {
        if (u == m * n + 1) {
            return true;
        }
        for (int i = 0; i < 8; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (isNotBorder(nx, ny) && !isFault[nx][ny] && !vis[nx][ny]) {
                vis[nx][ny] = true;
                path[u] = String.valueOf(c[nx]) + ny;
                isFault[nx][ny] = dfs(u + 1, nx, ny);
                if (isFault[nx][ny]) return true;
                vis[nx][ny] = false;
            }
        }
        return false;
    }

    static boolean isNotBorder(int x, int y) {
        return x >= 1 && x <= n && y >= 1 && y <= m;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}